<template>
  <div id="app">
    <router-view  v-slot="{ Component, route}">
      <transition :name="transitionName">
        <!-- 缓存 -->
        <keep-alive v-if="route.meta.keepAlive">
          <component :is="Component" />
        </keep-alive>
        <!-- 非缓存 -->
        <component :is="Component" v-else />
      </transition>
    </router-view>
  </div>
</template>

<script>

export default {
  name: 'App',
  data () {
    return {
      transitionName: '',
    }
  },
  watch: {
    $route(to, from) {
      /*
        初始化 transition 动画
        内置fade-enter动画 css动画位于 src/assets/css/pageAnimation.css
      */
      this.transitionName = "fade"
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #fff;
}
.app-router {
  overflow: hidden;
}
</style>
